//
// Created by LONG on 2020/11/2.
//

#ifndef O5G_SRC_CCORE_MISC_INCLUDE_IFMACRO_H_
#define O5G_SRC_CCORE_MISC_INCLUDE_IFMACRO_H_

#include "../../include/commDef.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define NO_RETURN_VALUE
#define NO_LOG_MESSAGE  (NULL)

#define IF_RETURN(OPERATOR, EXPECTED, EXPRESSION, RETVAL, FMT, ...) \
if((EXPECTED) OPERATOR (EXPRESSION)) \
{\
    if ((const char*)FMT)\
    {\
        CSP_LOG_ERR(0, (const char*)FMT ? FMT : " ", __VA_ARGS__);\
    }\
    return RETVAL;\
} do {} while(0)

#define IF_CONTINUE(OPERATOR, EXPECTED, EXPRESSION, FMT, ...) \
if((EXPECTED) OPERATOR (EXPRESSION)) \
{\
    if ((const char*)FMT)\
    {\
        CSP_LOG_ERR(0, (const char*)FMT ? FMT : " ", __VA_ARGS__);\
    }\
    continue;\
} do {} while(0)

#define IF_BREAK(OPERATOR, EXPECTED, EXPRESSION, FMT, ...) \
if((EXPECTED) OPERATOR (EXPRESSION)) \
{\
    if ((const char*)FMT)\
    {\
        CSP_LOG_ERR(0, (const char*)FMT ? FMT : " ", __VA_ARGS__);\
    }\
    break;\
} do {} while(0)

#ifdef __cplusplus
}
#endif

#endif //O5G_SRC_CCORE_MISC_INCLUDE_IFMACRO_H_
